package com.my.cd.bridge;

/**
 * 不同的遥控板接口扩展实现：添加去直接频道和返回频道的功能
 */
public class ControlPadBetter extends AbstractControlPad {
    private int ch = 0;
    private boolean ison = false;
    private int prech = 0;

    public ControlPadBetter(TVControl control) {
        super(control);
    }

    @Override
    public void onoff() {
        if (ison) {
            ison = false;
            control.off();
        } else {
            ison = true;
            control.on();
        }
    }

    @Override
    public void nextChannel() {
        prech = ch;
        ch++;
        control.setChannel(ch);
    }

    @Override
    public void preChannel() {
        prech = ch;
        ch--;
        if (ch < 0) {
            ch = 200;
        }
        control.setChannel(ch);
    }

    public void setChannel(int nch) {
        prech = ch;
        ch = nch;
        control.setChannel(ch);
    }

    public void back() {
        control.setChannel(prech);
    }
}
